Skip to content

fix: handle Amazon gift-card orders and non-reducing non-bank charge entries#26

Merged
eshaffer321 merged 2 commits into
eshaffer321:mainfrom
denniswalker:fix/amazon-giftcard-and-charge-validation
Jun 3, 2026
Merged

fix: handle Amazon gift-card orders and non-reducing non-bank charge entries#26
eshaffer321 merged 2 commits into
eshaffer321:mainfrom
denniswalker:fix/amazon-giftcard-and-charge-validation

Conversation

@denniswalker
Copy link
Copy Markdown
Contributor

Summary

  • Gift-card-only orders now skip instead of error: Introduced ErrGiftCardOrder sentinel in amazon/order.go. The handler detects it via errors.Is and sets result.Skipped = true with reason "paid entirely with gift cards/points" — previously these logged as ERROR and halted processing of subsequent orders.
  • Charge validator accepts bank-equals-full-total as valid: ValidateCharges now passes when bankSum ≈ orderTotal, covering promotional credits / rewards-earned entries that appear in Amazon's transaction list but don't actually reduce the card charge — previously these caused a spurious "bank charges exceed expected" warning and the order was skipped.
  • Both bugs documented in docs/bug-fixes.md with reproduction order IDs.

Test plan

  • TestAmazonHandler_ProcessOrder_FullyGiftCardOrder — new test; handler returns Skipped=true, no error
  • TestOrder_GetFinalCharges_OnlyGiftCard — updated to use errors.Is(err, ErrGiftCardOrder)
  • TestValidateCharges_BankMatchesOrderTotalWithNonBankEntry — new test; validates order 113-6125291-9439466 scenario passes
  • go test ./... — all existing tests continue to pass

🤖 Generated with Claude Code

denniswalker and others added 2 commits May 31, 2026 08:58
…entries

- Introduce ErrGiftCardOrder sentinel; handler now skips (not errors) orders
  paid entirely with gift cards/points
- ValidateCharges passes when bank sum equals full order total, covering
  promotional credits/rewards-earned entries that don't reduce the card charge
- Update tests to use errors.Is(err, ErrGiftCardOrder) and add regression cases
  for both bugs (orders 112-4444156-8489869 and 113-6125291-9439466)
- Document both fixes in docs/bug-fixes.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd-charge-validation

# Conflicts:
#	docs/bug-fixes.md
@eshaffer321 eshaffer321 merged commit 216b757 into eshaffer321:main Jun 3, 2026
5 of 6 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.69%. Comparing base (a2817a6) to head (464123f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/application/sync/handlers/amazon.go 72.72% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   56.54%   56.69%   +0.15%     
==========================================
  Files          43       43              
  Lines        4830     4847      +17     
==========================================
+ Hits         2731     2748      +17     
- Misses       1933     1934       +1     
+ Partials      166      165       -1     
Flag Coverage Δ
unittests 56.69% <85.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/adapters/providers/amazon/order.go 75.72% <100.00%> (ø)
internal/domain/validator/charges.go 100.00% <100.00%> (ø)
internal/application/sync/handlers/amazon.go 68.55% <72.72%> (+1.52%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants